home *** CD-ROM | disk | FTP | other *** search
- /*
- File: Cheap_Studio.c
-
- Contains:
-
- Written by: Mark Cookson
-
- Copyright: Copyright © 1996-1999 by Apple Computer, Inc., All Rights Reserved.
-
- You may incorporate this Apple sample source code into your program(s) without
- restriction. This Apple sample source code has been provided "AS IS" and the
- responsibility for its operation is yours. You are not permitted to redistribute
- this Apple sample source code as "Apple sample source code" after having made
- changes. If you're going to re-distribute the source, we require that you make
- it clear in the source that the code was descended from Apple sample source
- code, but that you've made changes.
-
- Change History (most recent first):
- 8/13/1999 Karl Groethe Updated for Metrowerks Codewarror Pro 2.1
-
-
- */
- #include <SoundInput.h>
- #include <Drag.h>
- #include <Gestalt.h>
-
- #include "SAL_Public.h"
- #include "SimpleApp_Sound.h"
-
- typedef struct {
- long sanitycheck;
- SPBPtr recordRec;
- Ptr pb0,
- pb1;
- Ptr recBuffer0,
- recBuffer1;
- Fixed sampleRate;
- OSType compression;
- unsigned long totalBytes;
- long myA5,
- devBuffer,
- soundRefNum;
- short whichBuffer,
- fileRefNum,
- numChannels,
- sampleSize;
- OSErr theErr; //last error returned by SPBRecord or PBWrite
- } Vars, *VarsPtr;
-
- OSErr PrepairToRecordToDisk (VarsPtr myVars);
- OSErr RecordToDisk (VarsPtr);
- OSErr FinishRecording (VarsPtr myVars);
-
- Vars myVars;
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MyIdleProc (const EventRecord *evt)
- {
- #ifndef __SC__
- #pragma unused (evt)
- #endif
-
- if (sound1Playing && ASoundIsDone (mySoundInfo1) == true) {
- ASoundDonePlaying (mySoundInfo1, nil);
- gSAL_CurrentControl = playButton1;
- sound1Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (sound2Playing && ASoundIsDone (mySoundInfo2) == true) {
- ASoundDonePlaying (mySoundInfo2, nil);
- gSAL_CurrentControl = playButton2;
- sound2Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (sound3Playing && ASoundIsDone (mySoundInfo3) == true) {
- ASoundDonePlaying (mySoundInfo3, nil);
- gSAL_CurrentControl = playButton3;
- sound3Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (sound4Playing && ASoundIsDone (mySoundInfo4) == true) {
- ASoundDonePlaying (mySoundInfo4, nil);
- gSAL_CurrentControl = playButton4;
- sound4Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (sound5Playing && ASoundIsDone (mySoundInfo5) == true) {
- ASoundDonePlaying (mySoundInfo5, nil);
- gSAL_CurrentControl = playButton5;
- sound5Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (sound6Playing && ASoundIsDone (mySoundInfo6) == true) {
- ASoundDonePlaying (mySoundInfo6, nil);
- gSAL_CurrentControl = playButton6;
- sound6Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- if (playAll == true) {
- if (!sound1Playing && !sound2Playing && !sound3Playing && !sound4Playing && !sound5Playing && !sound6Playing) {
- gSAL_CurrentControl = playAllButton;
- SAL_SetTitle ("\pPlay All");
- playAll = false;
- }
- } else {
- if (sound1Playing && sound2Playing && sound3Playing && sound4Playing && sound5Playing && sound6Playing) {
- gSAL_CurrentControl = playAllButton;
- SAL_SetTitle ("\pStop All");
- playAll = true;
- }
- }
- return noErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay1(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound1Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo1);
- theErr = ASoundReadyForPlaying (mySoundInfo1, nil);
- if (theErr == noErr) {
- sound1Set = true;
- sound1Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound1Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo1);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo1);
- if (theErr == noErr) {
- sound1Playing = true;
- gSAL_CurrentControl = playButton1;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo1);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay2(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound2Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo2);
- theErr = ASoundReadyForPlaying (mySoundInfo2, nil);
- if (theErr == noErr) {
- sound2Set = true;
- sound2Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound2Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo2);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo2);
- if (theErr == noErr) {
- sound2Playing = true;
- gSAL_CurrentControl = playButton2;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo2);
- }
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay3(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound3Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo3);
- theErr = ASoundReadyForPlaying (mySoundInfo3, nil);
- if (theErr == noErr) {
- sound3Set = true;
- sound3Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound3Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo3);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo3);
- if (theErr == noErr) {
- sound3Playing = true;
- gSAL_CurrentControl = playButton3;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo3);
- }
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay4 (const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound4Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo4);
- theErr = ASoundReadyForPlaying (mySoundInfo4, nil);
- if (theErr == noErr) {
- sound4Set = true;
- sound4Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound4Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo4);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo4);
- if (theErr == noErr) {
- sound4Playing = true;
- gSAL_CurrentControl = playButton4;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo4);
- }
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay5(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound5Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo5);
- theErr = ASoundReadyForPlaying (mySoundInfo5, nil);
- if (theErr == noErr) {
- sound5Set = true;
- sound5Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound5Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo5);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo5);
- if (theErr == noErr) {
- sound5Playing = true;
- gSAL_CurrentControl = playButton5;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo5);
- }
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlay6(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- if (sound6Set == false) {
- theErr = ASoundGetFileToPlay (mySoundInfo6);
- theErr = ASoundReadyForPlaying (mySoundInfo6, nil);
- if (theErr == noErr) {
- sound6Set = true;
- sound6Playing = false;
- SAL_SetTitle ("\pPlay");
- }
- } else {
- if (sound6Playing == false) {
- if (playAll == true) {
- SndCommand theCmd;
- SndChannelPtr theChan;
-
- theChan = ASoundGetChan (mySoundInfo6);
- theCmd.cmd = syncCmd;
- theCmd.param1 = soundsToSync;
- theCmd.param2 = 'scme';
- theErr = SndDoImmediate (theChan, &theCmd);
- }
- theErr = ASoundPlay (mySoundInfo6);
- if (theErr == noErr) {
- sound6Playing = true;
- gSAL_CurrentControl = playButton6;
- SAL_SetTitle ("\pStop");
- }
- } else {
- theErr = ASoundStop (mySoundInfo6);
- }
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoPlayAll(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- if (playAll == false) {
- playAll = true;
- soundsToSync = 0;
- if (sound1Set) soundsToSync++;
- if (sound2Set) soundsToSync++;
- if (sound3Set) soundsToSync++;
- if (sound4Set) soundsToSync++;
- if (sound5Set) soundsToSync++;
- if (sound6Set) soundsToSync++;
- if (sound1Set == true && sound1Playing == false) { theErr = DoPlay1(pButtonItemRef,pModifiers);soundsToSync--;}
- if (sound2Set == true && sound2Playing == false) { theErr = DoPlay2(pButtonItemRef,pModifiers);soundsToSync--;}
- if (sound3Set == true && sound3Playing == false) { theErr = DoPlay3(pButtonItemRef,pModifiers);soundsToSync--;}
- if (sound4Set == true && sound4Playing == false) { theErr = DoPlay4(pButtonItemRef,pModifiers);soundsToSync--;}
- if (sound5Set == true && sound5Playing == false) { theErr = DoPlay5(pButtonItemRef,pModifiers);soundsToSync--;}
- if (sound6Set == true && sound6Playing == false) { theErr = DoPlay6(pButtonItemRef,pModifiers);}
- gSAL_CurrentControl = playAllButton;
- SAL_SetTitle ("\pStop All");
- } else {
- playAll = false;
- if (sound1Set == true && sound1Playing == true) theErr = DoPlay1(pButtonItemRef,pModifiers);
- if (sound2Set == true && sound2Playing == true) theErr = DoPlay2(pButtonItemRef,pModifiers);
- if (sound3Set == true && sound3Playing == true) theErr = DoPlay3(pButtonItemRef,pModifiers);
- if (sound4Set == true && sound4Playing == true) theErr = DoPlay4(pButtonItemRef,pModifiers);
- if (sound5Set == true && sound5Playing == true) theErr = DoPlay5(pButtonItemRef,pModifiers);
- if (sound6Set == true && sound6Playing == true) theErr = DoPlay6(pButtonItemRef,pModifiers);
- gSAL_CurrentControl = playAllButton;
- SAL_SetTitle ("\pPlay All");
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr DoRecord (const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
-
- if (!recording) {
- if (!prepairedToRecord) {
- theErr = PrepairToRecordToDisk (&myVars);
- if (theErr == noErr) {
- prepairedToRecord = true;
- gSAL_CurrentControl = recordButton;
- SAL_SetTitle ("\pRecord&Play");
- }
- } else {
- DoPlayAll(pButtonItemRef,pModifiers);
- theErr = RecordToDisk (&myVars);
- recording = true;
- gSAL_CurrentControl = recordButton;
- SAL_SetTitle ("\pStop record");
- }
- } else {
- theErr = FinishRecording (&myVars);
- recording = false;
- DoPlayAll(pButtonItemRef,pModifiers);
- prepairedToRecord = false;
- gSAL_CurrentControl = recordButton;
- SAL_SetTitle ("\pSetup Rec");
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound1(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck1, !GetControlValue (muteCheck1));
- theErr = ASoundGetVolume (mySoundInfo1, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo1, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo1, 0x100, 0x100);
- }
-
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound2(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck2, !GetControlValue (muteCheck2));
- theErr = ASoundGetVolume (mySoundInfo2, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo2, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo2, 0x100, 0x100);
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound3(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck3, !GetControlValue (muteCheck3));
- theErr = ASoundGetVolume (mySoundInfo3, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo3, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo3, 0x100, 0x100);
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound4(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck4, !GetControlValue (muteCheck4));
- theErr = ASoundGetVolume (mySoundInfo4, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo4, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo4, 0x100, 0x100);
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound5(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck5, !GetControlValue (muteCheck5));
- theErr = ASoundGetVolume (mySoundInfo5, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo5, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo5, 0x100, 0x100);
- }
- return theErr;
- }
-
- /*-----------------------------------------------------------------------*/
- static pascal OSErr MuteSound6(const ButtonItemRef pButtonItemRef,const SInt32 pModifiers)
- {
- OSErr theErr;
- unsigned short leftVol, rightVol;
-
- #pragma unused (pButtonItemRef,pModifiers)
-
- SetControlValue (muteCheck6, !GetControlValue (muteCheck6));
- theErr = ASoundGetVolume (mySoundInfo6, &leftVol, &rightVol);
- if (leftVol != 0 || rightVol != 0) {
- theErr = ASoundSetVolume (mySoundInfo6, 0, 0);
- } else {
- theErr = ASoundSetVolume (mySoundInfo6, 0x100, 0x100);
- }
- return theErr;
- }
-
- static pascal OSErr ClearAllSounds (long menuResult)
- {
- #pragma unused (menuResult)
- OSErr err;
-
- mySoundInfo1 = ASoundNew (&err);
- mySoundInfo2 = ASoundNew (&err);
- mySoundInfo3 = ASoundNew (&err);
- mySoundInfo4 = ASoundNew (&err);
- mySoundInfo5 = ASoundNew (&err);
- mySoundInfo6 = ASoundNew (&err);
-
- sound1Set = false;
- sound2Set = false;
- sound3Set = false;
- sound4Set = false;
- sound5Set = false;
- sound6Set = false;
-
- gSAL_CurrentControl = playButton1;
- SAL_SetTitle ("\pLoad Sound 1");
- gSAL_CurrentControl = playButton2;
- SAL_SetTitle ("\pLoad Sound 2");
- gSAL_CurrentControl = playButton3;
- SAL_SetTitle ("\pLoad Sound 3");
- gSAL_CurrentControl = playButton4;
- SAL_SetTitle ("\pLoad Sound 4");
- gSAL_CurrentControl = playButton5;
- SAL_SetTitle ("\pLoad Sound 5");
- gSAL_CurrentControl = playButton6;
- SAL_SetTitle ("\pLoad Sound 6");
-
- return err;
- }
-
- /*-----------------------------------------------------------------------*/
- void main (void)
- {
- Rect r;
- long soundAttr;
- short err;
-
- SAL_InitSimpleApp (2, kSAL_UseStandardMenu); /* Simple App Sets up the Tool Box For us */
- SAL_GetDocumentWindow(128,nil); /* Get our stored window */
-
- SAL_SetRectLocation(&r, 10, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions(&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton(1, gSAL_CurrentWindow, "\pLoad Sound 1", &r, (char)0, DoPlay1,nil);
- playButton1 = gSAL_CurrentControl;
-
- SAL_SetRectLocation(&r, 130, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions(&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (2, gSAL_CurrentWindow, "\pLoad Sound 2", &r, (char)0, DoPlay2,nil);
- playButton2 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 270, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (3, gSAL_CurrentWindow, "\pLoad Sound 3", &r, (char)0, DoPlay3,nil);
- playButton3 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 10, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (4, gSAL_CurrentWindow, "\pLoad Sound 4", &r, (char)0, DoPlay4,nil);
- playButton4 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 130, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (5, gSAL_CurrentWindow, "\pLoad Sound 5", &r, (char)0, DoPlay5,nil);
- playButton5 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 270, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (6, gSAL_CurrentWindow, "\pLoad Sound 6", &r, (char)0, DoPlay6,nil);
- playButton6 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 10, 50); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (7, gSAL_CurrentWindow, "\pSetup Rec", &r, (char)0, DoRecord,nil);
- recordButton = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 110, 80); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallPushButton (8, gSAL_CurrentWindow, "\pPlay All", &r, (char)0, DoPlayAll,nil);
- playAllButton = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 110, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (9, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound1,nil);
- muteCheck1 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 250, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (10, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound2,nil);
- muteCheck2 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 370, 2); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (11, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound3,nil);
- muteCheck3 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 110, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (12, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound4,nil);
- muteCheck4 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 250, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (13, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound5,nil);
- muteCheck5 = gSAL_CurrentControl;
-
- SAL_SetRectLocation (&r, 370, 25); /* This Sets a rects anchor point */
- SAL_SetRectDimensions (&r, 90, 20); /* This Sets its size without changing it position */
- err = SAL_InstallCheckBox (14, gSAL_CurrentWindow, "\p", &r , (char)0, 1, MuteSound6,nil);
- muteCheck6 = gSAL_CurrentControl;
-
- mySoundInfo1 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo2 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo3 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo4 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo5 = ASoundNew (&err);
- if (err == noErr)
- mySoundInfo6 = ASoundNew (&err);
-
- SAL_InstallMenuItem (130, 9, "\pClear all sounds", 0, 'R', ClearAllSounds, nil);
- SAL_InstallIdleProc(MyIdleProc);
-
- err = Gestalt (gestaltSoundAttr, &soundAttr);
- if ((soundAttr & (1 << gestaltPlayAndRecord)) == false) {
- DebugStr ("\pCan't play and record simultaniously.");
- }
-
- if (err == noErr)
- SAL_Run(); /* Let SimpleApp handle the rest */
- }
-
- // utility functions since I already keep the control handle around
- /*-----------------------------------------------------------------------*/
- static void EnableControl (ControlRef cr)
- {
- if (cr != nil) {
- HiliteControl(cr, nil);
- }
- }
-
- /*-----------------------------------------------------------------------*/
- static void DisableControl (ControlRef cr)
- {
- if (cr != nil) {
- HiliteControl(cr, 255);
- }
- }
-